import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MiningVO, MiningForm, MiningQuery } from '@/api/business/mining/types';

/**
 * 查询矿机列表
 * @param query
 * @returns {*}
 */

export const listMining = (query?: MiningQuery): AxiosPromise<MiningVO[]> => {
  return request({
    url: '/business/mining/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询矿机详细
 * @param id
 */
export const getMining = (id: string | number): AxiosPromise<MiningVO> => {
  return request({
    url: '/business/mining/' + id,
    method: 'get'
  });
};

/**
 * 新增矿机
 * @param data
 */
export const addMining = (data: MiningForm) => {
  return request({
    url: '/business/mining',
    method: 'post',
    data: data
  });
};

/**
 * 修改矿机
 * @param data
 */
export const updateMining = (data: MiningForm) => {
  return request({
    url: '/business/mining',
    method: 'put',
    data: data
  });
};

/**
 * 删除矿机
 * @param id
 */
export const delMining = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/mining/' + id,
    method: 'delete'
  });
};
